package k.daniel.databindingdemo.bean;

import android.databinding.BaseObservable;
import android.databinding.Bindable;

import k.daniel.databindingdemo.BR;

public class ObservableUserBean extends BaseObservable {
    public String firstName;
    public String lastName;
    public int age;
    public boolean gender;
    public String imageUrl;

    public ObservableUserBean(String firstName, String lastName, int age, boolean gender,String imageUrl) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.age = age;
        this.gender = gender;
        this.imageUrl=imageUrl;
    }


    public void setFirstName(String firstName) {
        this.firstName = firstName;
        System.out.println("First Name 变了");
        notifyPropertyChanged(BR.firstName);
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public void setAge(int age) {
        this.age = age;
        notifyPropertyChanged(BR.age);
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }
    @Bindable
    public String getFirstName() {
        return firstName;
    }
    @Bindable
    public String getLastName() {
        return lastName;
    }
    @Bindable
    public int getAge() {
        return age;
    }

    public boolean isGender() {
        return gender;
    }

    @Override
    public String toString() {
        return "UserBean{" +
                "firstName='" + firstName + '\'' +
                ", lastName='" + lastName + '\'' +
                ", age=" + age +
                ", gender=" + gender +
                '}';
    }
}
